package com.wxm.killing.mq.producer;

import org.apache.activemq.command.ActiveMQQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

/**
 * @Description 消息生产者
 * @author: wxm
 * @date: 2019/10/10 23:00
 * @version: 1.0
 */
@Component
public class JMSProducer {
    private final static Logger logger = LoggerFactory.getLogger(JMSProducer.class);

    @Autowired
    private JmsTemplate jmsTemplate;

    public void sendKillingMessage(String message) {
        logger.info("生产消息：{}",message);
        Destination destination = new ActiveMQQueue("rushBuy.queue");
        this.jmsTemplate.convertAndSend(destination,message);
    }
}
